package com.ruoyi.foreign_language.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.foreign_language.domain.TbForeignLanguage;
import com.ruoyi.foreign_language.service.ITbForeignLanguageService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 外语语种信息Controller
 * 
 * @author ruoyi
 * @date 2024-12-02
 */
@RestController
@RequestMapping("/foreign_language/foreign_language")
public class TbForeignLanguageController extends BaseController
{
    @Autowired
    private ITbForeignLanguageService tbForeignLanguageService;

    /**
     * 查询外语语种信息列表
     */
    @PreAuthorize("@ss.hasPermi('foreign_language:foreign_language:list')")
    @GetMapping("/list")
    public TableDataInfo list(TbForeignLanguage tbForeignLanguage)
    {
        startPage();
        List<TbForeignLanguage> list = tbForeignLanguageService.selectTbForeignLanguageList(tbForeignLanguage);
        return getDataTable(list);
    }

    /**
     * 导出外语语种信息列表
     */
    @PreAuthorize("@ss.hasPermi('foreign_language:foreign_language:export')")
    @Log(title = "外语语种信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TbForeignLanguage tbForeignLanguage)
    {
        List<TbForeignLanguage> list = tbForeignLanguageService.selectTbForeignLanguageList(tbForeignLanguage);
        ExcelUtil<TbForeignLanguage> util = new ExcelUtil<TbForeignLanguage>(TbForeignLanguage.class);
        util.exportExcel(response, list, "外语语种信息数据");
    }

    /**
     * 获取外语语种信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('foreign_language:foreign_language:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(tbForeignLanguageService.selectTbForeignLanguageById(id));
    }

    /**
     * 新增外语语种信息
     */
    @PreAuthorize("@ss.hasPermi('foreign_language:foreign_language:add')")
    @Log(title = "外语语种信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TbForeignLanguage tbForeignLanguage)
    {
        return toAjax(tbForeignLanguageService.insertTbForeignLanguage(tbForeignLanguage));
    }

    /**
     * 修改外语语种信息
     */
    @PreAuthorize("@ss.hasPermi('foreign_language:foreign_language:edit')")
    @Log(title = "外语语种信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TbForeignLanguage tbForeignLanguage)
    {
        return toAjax(tbForeignLanguageService.updateTbForeignLanguage(tbForeignLanguage));
    }

    /**
     * 删除外语语种信息
     */
    @PreAuthorize("@ss.hasPermi('foreign_language:foreign_language:remove')")
    @Log(title = "外语语种信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(tbForeignLanguageService.deleteTbForeignLanguageByIds(ids));
    }
}
